var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var i in t) t.hasOwnProperty(i) && (e[i] = t[i]);
    })(e, t);
}, function(e, t) {
    function i() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype, 
    new i());
}), a = this && this.__decorate || function(e, t, i, r) {
    var n, o = arguments.length, l = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, i) : r;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) l = Reflect.decorate(e, t, i, r); else for (var s = e.length - 1; 0 <= s; s--) (n = e[s]) && (l = (o < 3 ? n(l) : 3 < o ? n(t, i, l) : n(t, i)) || l);
    return 3 < o && l && Object.defineProperty(t, i, l), l;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = cc._decorator, s = r.ccclass, c = r.property, l = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.green = null, e.red = null, e.black = null, e.numLabel = null, e.value = 0, 
        e.max = 0, e.d = 0, e.x = 1e3, e;
    }
    return i(e, t), e.prototype.start = function() {}, e.prototype.init = function(e) {
        this.max = e, this.value = e, this.d = this.green.node.width / Math.floor(this.max / this.x), 
        this.numLabel && (this.numLabel.string = "生命值 " + this.max), this.black.clear();
        var t = Math.floor(this.max / this.x), i = -this.green.node.width / 2, r = -this.green.node.height / 2;
        this.black.lineWidth = 2;
        for (var n = 0; n < t; n++) {
            var o = i + this.d * (n + 1);
            o < -i && (this.black.moveTo(o, r), this.black.lineTo(o, r + this.green.node.height));
        }
        this.black.stroke(), this.reset();
    }, e.prototype.reset = function() {
        this.node.active = !0, this.red && (this.red.fillRange = 1), this.refresh(this.max);
    }, e.prototype.refresh = function(e) {
        this.value = e, 0 < this.max && (this.green.fillRange = this.value / this.max);
    }, e.prototype.update = function(e) {
        this.green && (this.green.fillRange < this.value / this.max ? this.green.fillRange += e / 3 : this.green.fillRange != this.value / this.max && (this.green.fillRange = this.value / this.max)), 
        this.red && (this.red.fillRange > this.green.fillRange ? this.red.fillRange -= e / 5 : this.red.fillRange != this.green.fillRange && (this.red.fillRange = this.green.fillRange));
    }, a([ c(cc.Sprite) ], e.prototype, "green", void 0), a([ c(cc.Sprite) ], e.prototype, "red", void 0), 
    a([ c(cc.Graphics) ], e.prototype, "black", void 0), a([ c(cc.Label) ], e.prototype, "numLabel", void 0), 
    a([ s ], e);
}(cc.Component);

n.default = l;